/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/15
\**********************/
#include "LuaEdit.h"

#define CObjPtr ((CEditUI*)m_cobj)

namespace DuiLib {

void LuaEdit::SetEnabled(bool bEnable)
{
    CObjPtr->SetEnabled(bEnable);
}

int LuaEdit::SetText(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetText(str.c_str());
    return 0;
}

void LuaEdit::SetMaxChar(UINT uMax)
{
    CObjPtr->SetMaxChar(uMax);
}

UINT LuaEdit::GetMaxChar()
{
    return CObjPtr->GetMaxChar();
}

void LuaEdit::SetReadOnly(bool bReadOnly)
{
    CObjPtr->SetReadOnly(bReadOnly);
}

bool LuaEdit::IsReadOnly()
{
    return CObjPtr->IsReadOnly();
}

void LuaEdit::SetPasswordMode(bool bPasswordMode)
{
    CObjPtr->SetPasswordMode(bPasswordMode);
}

bool LuaEdit::IsPasswordMode()
{
    return CObjPtr->IsPasswordMode();
}

int LuaEdit::SetPasswordChar(LuaState *L)
{
    LuaStack args(L);
    SDTChar val = LuaHelperNS::GetTChar(args[2]);
    CObjPtr->SetPasswordChar(val);
    return 0;
}

int LuaEdit::GetPasswordChar(LuaState *L)
{
    SDTChar val = CObjPtr->GetPasswordChar();
    LuaHelperNS::PushTChar(L, val);
    return 1;
}

void LuaEdit::SetNumberOnly(bool bNumberOnly)
{
    CObjPtr->SetNumberOnly(bNumberOnly);
}

bool LuaEdit::IsNumberOnly()
{
    return CObjPtr->IsNumberOnly();
}

int LuaEdit::GetWindowStyls()
{
    return CObjPtr->GetWindowStyls();
}

int LuaEdit::GetNormalImage(LuaState *L)
{
    SDTString str = CObjPtr->GetNormalImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaEdit::SetNormalImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetNormalImage(str.c_str());
    return 0;
}

int LuaEdit::GetHotImage(LuaState *L)
{
    SDTString str = CObjPtr->GetHotImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaEdit::SetHotImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetHotImage(str.c_str());
    return 0;
}

int LuaEdit::GetFocusedImage(LuaState *L)
{
    SDTString str = CObjPtr->GetFocusedImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaEdit::SetFocusedImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetFocusedImage(str.c_str());
    return 0;
}

int LuaEdit::GetDisabledImage(LuaState *L)
{
    SDTString str = CObjPtr->GetDisabledImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaEdit::SetDisabledImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetDisabledImage(str.c_str());
    return 0;
}

void LuaEdit::SetNativeEditBkColor(DWORD dwBkColor)
{
    CObjPtr->SetNativeEditBkColor(dwBkColor);
}

DWORD LuaEdit::GetNativeEditBkColor()
{
    return CObjPtr->GetNativeEditBkColor();
}

int LuaEdit::SetNativeEditTextColor(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetNativeEditTextColor(str.c_str());
    return 0;
}

DWORD LuaEdit::GetNativeEditTextColor()
{
    return CObjPtr->GetNativeEditTextColor();
}

void LuaEdit::SetSel(long nStartChar, long nEndChar)
{
    CObjPtr->SetSel(nStartChar, nEndChar);
}

void LuaEdit::SetSelAll()
{
    CObjPtr->SetSelAll();
}

int LuaEdit::SetReplaceSel(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetReplaceSel(str.c_str());
    return 0;
}

int LuaEdit::SetTipValue(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetTipValue(str.c_str());
    return 0;
}

int LuaEdit::GetTipValue(LuaState *L)
{
    SDTString str = CObjPtr->GetTipValue();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaEdit::SetTipValueColor(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetTipValueColor(str.c_str());
    return 0;
}

DWORD LuaEdit::GetTipValueColor()
{
    return CObjPtr->GetTipValueColor();
}

int LuaEdit::SetPos(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    bool bNeedInvalidate = LuaHelperNS::GetBool(args[3], true);
    CObjPtr->SetPos(rc, bNeedInvalidate);
    return 0;
}

int LuaEdit::Move(LuaState *L)
{
    LuaStack args(L);
    SIZE sz = LuaHelperNS::GetSize(args[2]);
    bool bNeedInvalidate = LuaHelperNS::GetBool(args[3], true);
    CObjPtr->Move(sz, bNeedInvalidate);
    return 0;
}

void LuaEdit::SetVisible(bool bVisible)
{
    CObjPtr->SetVisible(bVisible);
}

void LuaEdit::SetInternVisible(bool bVisible)
{
    CObjPtr->SetInternVisible(bVisible);
}

int LuaEdit::EstimateSize(LuaState *L)
{
    LuaStack args(L);
    SIZE szAvailable = LuaHelperNS::GetSize(args[2]);
    SIZE sz = CObjPtr->EstimateSize(szAvailable);
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

SDLUA_BEGIN_REGISTER(LuaEdit, Edit, Label)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetEnabled, SetEnabled)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, SetText, SetText)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetMaxChar, SetMaxChar)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, GetMaxChar, GetMaxChar)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetReadOnly, SetReadOnly)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, IsReadOnly, IsReadOnly)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetPasswordMode, SetPasswordMode)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, IsPasswordMode, IsPasswordMode)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, GetPasswordChar, GetPasswordChar)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, SetPasswordChar, SetPasswordChar)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetNumberOnly, SetNumberOnly)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, IsNumberOnly, IsNumberOnly)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, GetWindowStyls, GetWindowStyls)

    SDLUA_REGISTER_FUN_LUA(LuaEdit, GetNormalImage, GetNormalImage)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, SetNormalImage, SetNormalImage)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, GetHotImage, GetHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, SetHotImage, SetHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, GetFocusedImage, GetFocusedImage)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, SetFocusedImage, SetFocusedImage)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, GetDisabledImage, GetDisabledImage)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, SetDisabledImage, SetDisabledImage)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetNativeEditBkColor, SetNativeEditBkColor)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, GetNativeEditBkColor, GetNativeEditBkColor)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, SetNativeEditTextColor, SetNativeEditTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, GetNativeEditTextColor, GetNativeEditTextColor)
    
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetSel, SetSel)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetSelAll, SetSelAll)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetReplaceSel, SetReplaceSel)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, SetTipValue, SetTipValue)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, GetTipValue, GetTipValue)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, SetTipValueColor, SetTipValueColor)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, GetTipValueColor, GetTipValueColor)

    SDLUA_REGISTER_FUN_LUA(LuaEdit, SetPos, SetPos)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, Move, Move)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetVisible, SetVisible)
    SDLUA_REGISTER_FUN_CPP(LuaEdit, SetInternVisible, SetInternVisible)
    SDLUA_REGISTER_FUN_LUA(LuaEdit, EstimateSize, EstimateSize)
    
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaEdit, Edit)
SDLUA_END_UNREGISTER(Edit)

}

#undef CObjPtr